home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Visual Basic Source Code
/
Visual Basic Source Code.iso
/
vbsource
/
favour1a
/
form1.frm
< prev
next >
Wrap
Text File
|
1999-10-22
|
8KB
|
246 lines
VERSION 5.00
Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCTL.OCX"
Begin VB.Form frmHistory
Caption = "Favourites Manager"
ClientHeight = 3480
ClientLeft = 3720
ClientTop = 2490
ClientWidth = 6000
ForeColor = &H00400040&
Icon = "Form1.frx":0000
LinkTopic = "Form1"
MaxButton = 0 'False
ScaleHeight = 3480
ScaleWidth = 6000
StartUpPosition = 2 'CenterScreen
Begin VB.CommandButton cmdReload
Caption = "Reload"
Height = 375
Left = 4440
TabIndex = 4
ToolTipText = "Reload Favorites"
Top = 1680
Width = 1335
End
Begin VB.TextBox txtShow
Enabled = 0 'False
Height = 375
Left = 3390
Locked = -1 'True
TabIndex = 6
TabStop = 0 'False
ToolTipText = "LOCKED"
Top = 2700
Width = 2415
End
Begin VB.CommandButton cmdDelete
Caption = "Delete"
Height = 375
Left = 4440
TabIndex = 3
ToolTipText = "Delete a Favorite"
Top = 1200
Width = 1335
End
Begin VB.TextBox txtAdd
Height = 375
Left = 3390
TabIndex = 5
ToolTipText = "Type Favorite to Add in Here"
Top = 2205
Width = 2415
End
Begin VB.CommandButton cmdSave
Caption = "Save"
Height = 375
Left = 4440
TabIndex = 2
ToolTipText = "Save Favorites"
Top = 720
Width = 1335
End
Begin VB.CommandButton cmdAdd
Caption = "Add"
Height = 375
Left = 4440
TabIndex = 1
ToolTipText = "Add a Favorite"
Top = 240
Width = 1335
End
Begin MSComctlLib.ListView lvFav
Height = 3255
Left = 120
TabIndex = 0
TabStop = 0 'False
ToolTipText = "Favorites List"
Top = 120
Width = 3165
_ExtentX = 5583
_ExtentY = 5741
View = 3
Arrange = 1
Sorted = -1 'True
MultiSelect = -1 'True
LabelWrap = -1 'True
HideSelection = -1 'True
AllowReorder = -1 'True
FlatScrollBar = -1 'True
FullRowSelect = -1 'True
GridLines = -1 'True
HotTracking = -1 'True
HoverSelection = -1 'True
_Version = 393217
ForeColor = 255
BackColor = 3199960
BorderStyle = 1
Appearance = 1
NumItems = 1
BeginProperty ColumnHeader(1) {BDD1F052-858B-11D1-B16A-00C0F0283628}
Text = "Sites"
Object.Width = 5380
EndProperty
End
End
Attribute VB_Name = "frmHistory"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
'##################################################
'# Code by Andy McCurtin #
'# You may use this code freely in any of your #
'# programs I would however appreiciate it if #
'# you improve this code in any way that you #
'# send me a copy of the update code #
'# #
'# e-mail : moon_2@hotmail.com #
'# #
'# Happy Programming #
'##################################################
Option Explicit
'############### Global Variable Declarations #####
Dim a() As String
Dim i As Integer
Dim ItemCount
'##################################################
Private Sub CmdAdd_Click()
Dim itm As ListItem 'set itm as lvFav.listitem
If txtAdd.Text = "" Then 'if txtAdd has nothing in it diplay msgbox
MsgBox "Please enter something to add", vbInformation, "Favourites Manager"
Else 'otherwise add the text in txtAdd to lvFav
Set itm = lvFav.ListItems.Add(, , txtAdd.Text)
End If
txtAdd.Text = "" 'clear txtAdd
End Sub
Private Sub cmdDelete_Click()
'if the list count is 0 and no items are selected
'or selected item is index 1 display msgbox
If Not lvFav.ListItems.Count = 0 And Not lvFav.SelectedItem.Selected Or lvFav.SelectedItem.Index = 1 Then
MsgBox "Nothing to delete", vbInformation, "Favourites Manager"
Else 'otherwise remove selected item
lvFav.ListItems.Remove lvFav.SelectedItem.Index
End If
cmdReload.Enabled = True 're-enable cmdReload
End Sub
Private Sub cmdReload_Click()
'######## Declare loacal variables ##############
Dim itm As ListItem 'set itm as lvFav.listitem
Dim a As String 'set a as a string
Dim b As String 'set b as a string
'################################################
lvFav.ListItems.Clear 'clear contents of lvFav to
'prevent over writing files
b = "Select an item from below" 'set b as text
Set itm = lvFav.ListItems.Add(, , b) 'add b to lvFav
'####### Opens & loads text file into lvFav #########
Open App.Path & "\Favourites .txt" For Input As #1
Do Until EOF(1)
Input #1, a
Set itm = lvFav.ListItems.Add(, , a)
Loop
Close #1
'################################################
cmdReload.Enabled = False 're-enable cmdReload
End Sub
Private Sub CmdSave_Click()
'set itemcount as lvFav.listitems.count
ItemCount = frmHistory.lvFav.ListItems.Count
For i = 2 To ItemCount 'load from index 2 to total
ReDim Preserve a(i) As String
a(i) = frmHistory.lvFav.ListItems(i).Text 'set a as lvFav.listitems text i.e. www.microsoft.com
Next i 'load next item
'######### opens file for appending ###############
Open App.Path & "\Favourites .txt" For Output As #1
For i = 2 To ItemCount
Write #1, a(i)
Next i
Close #1
'##################################################
cmdReload.Enabled = True 're-enable cmdReload
End Sub
Private Sub Form_Load()
'######## Declare loacal variables ##############
Dim itm As ListItem 'set itm as lvFavFav.listitem
Dim a As String 'set a as a string
Dim b As String 'set b as a string
'################################################
lvFav.ListItems.Clear 'clear contents of lvFavFav to
'prevent over writing files
b = "Select an item from below" 'set b as text
Set itm = lvFav.ListItems.Add(, , b) 'add b to lvFav
'####### Opens & loads text file into lvFav #########
Open App.Path & "\Favourites .txt" For Input As #1
Do Until EOF(1)
Input #1, a
Set itm = lvFav.ListItems.Add(, , a)
Loop
Close #1
'################################################
End Sub
Private Sub lvFav_Click()
If lvFav.ListItems.Count = 0 Then 'if no items to select then display msgbox
MsgBox "No items to select", vbInformation, "Favourites Manager"
Else 'otherwise set txtShow.text as lvFav.items text this can be used to tranfer to combobox for
'URL browsing
txtShow.Text = lvFav.SelectedItem
End If
End Sub
Private Sub lvFav_LostFocus()
txtShow.Text = "" 'when lvFav loses focus clear txtShow
End Sub